﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Simhopp.Model;
using Simhopp.GUI;

namespace Simhopp.Presenter
{
    class PresenterEditDiver
    {
        public InterfaceCompetitionModel _modelCompetition { get; set; }
        public InterfaceEditDiverView _view { get; set; }
        public InterfaceDiverModel _modelDiver { get; set; }
        public PresenterEditDiver(InterfaceEditDiverView view, InterfaceCompetitionModel modelCompetition)
        {
            this._modelDiver = null;
            this._modelCompetition = modelCompetition;
            this._view = view;
            this._view.EventAddDiver +=_view_EventAddDiver;
            this._view.EventRemoveDiver += _view_EventRemoveDiver;
            this._view.EventUpdateDiver += _view_EventUpdateDiver;
            this._view.EventAddDive += _view_EventAddDive;
            this._view.EventRemoveDive += _view_EventRemoveDive;
            this._view.EventGetDiverList += _view_EventGetDiverList;
            this._view.EventGetDiveList += _view_EventGetDiveList;
            this._view.EventGetAllDivesFromDatabase += _view_EventGetAllDivesFromDatabase;
            this._view.EventAddExistingDiver += _view_EventAddExistingDiver;
            this._view.EventUpdateDiverList += _view_EventUpdateDiverList;
            this._view.EventUpdateCompleteDiverList += _view_EventUpdateCompleteDiverList;
        }

        void _view_EventUpdateCompleteDiverList(List<Diver> diverList)
        {
            this._modelCompetition.GetCompleteDiverList(diverList);
        }

        List<Diver> _view_EventUpdateDiverList()
        {
            return this._modelCompetition.DiverList; 
        }

        void _view_EventAddExistingDiver(Diver diver)
        {
            this._modelCompetition.AddExistingDiver(diver);
        }

        List<Dive> _view_EventGetAllDivesFromDatabase()
        {
            return this._modelCompetition.GetAllDives();
        }

        List<Dive> _view_EventGetDiveList()
        {
            return this._modelDiver.DiveList;
        }

        List<Diver> _view_EventGetDiverList()
        {
            return this._modelCompetition.DiverList;
        }

        void _view_EventRemoveDive(Dive dive)
        {
            this._modelDiver.RemoveDive(dive.ID);
        }

        void _view_EventAddDive(Dive dive)
        {
            this._modelDiver.AddDive(dive.ID, dive.Name, dive.Difficulty, dive.NameCode, dive.DiveNumber);
        }

        void _view_EventUpdateDiver(Diver originalDiver, Diver updatedDiver)
        {
            this._modelCompetition.UpdateDiver(originalDiver, updatedDiver);
        }
        void _view_EventRemoveDiver(Diver diver)
        {
            this._modelCompetition.RemoveDiver(diver);
        }
        void _view_EventAddDiver(Diver diver)
        {
            this._modelCompetition.AddDiver(diver);
        }


    }
}
